import win32com.client
from pprint import pprint
import time

def x(*method, obj=None):
    for tu in method:
        if isinstance(tu, tuple):
            md, *args = tu
            print('#method ', md, end=':\n         ')
            pprint(getattr(obj, md)(*args))
        elif isinstance(tu, str):
            md = tu
            print('#method ', md, end=':\n         ')
            pprint(getattr(obj, md)())


inca = win32com.client.Dispatch('inca.inca')
print(inca)
# time.sleep(0.5)
# inca.SwitchToDataSet()
# inca.OpenDataBase('TEMP')
# time.sleep(0.5)
# inca.UnlockDatabase()
# time.sleep(0.5)
db = inca.GetCurrentDataBase()
assert db,'无法连接INCA数据库'
x('GetPrimaryRecordingFormatID','GetPrimaryRecordingFormatFileExtension','IsDatabaseLocked','GetDataBasePath',obj=inca)
a = db.BrowseItem('LEC4T_D1p1_Int_20201210')
for obj in a:
    x(
        'GetAccessRightApplication',
        'GetAccessRightCodeGeneration',
        'GetAccessRightExecute',
        'GetAccessRightRead',
        'GetAllReferecedDataBaseItems',
        'GetComment',
        # 'GetComponentType',
        'GetDataBase',
        'GetDisallowImport',
        'GetName',
        'GetNameWithPath',
        'GetOID',
        'GetParentFolder',
        'GetToolErrorCode',

        'IsAbstractBlockDiagramElement',
        'IsAbstractMethod',
        'IsAsap2CanDB',
        'IsAsap2Catalog',
        'IsAsap2Item',
        'IsAsap2Project',
        'IsAsap2ProjectFolder',
        'IsAscetContainer',
        'IsAscetDiagram',
        'IsAscetFolder',
        'IsAscetNetwork',
        'IsAscetProject',
        'IsAscetProjectFile',
        'IsAscetProtocol',
        'IsClass',
        'IsCodeComponent',
        'IsCodeGenerator',
        'IsComponent',
        'IsConditionalTable',
        'IsConfiguration',
        'IsConfigurationItem',
        'IsCTBlock',
        'IsCTComponent',
        'IsDataBaseItem',
        'IsDataBaseItem',
        'IsDataSet',
        'IsDeviceDescription',
        'IsDiscreteComponent',
        'IsEnumeration',
        'IsExperimentEnvironment',
        'IsFolder',
        'IsFormula',
        'IsFunctionalComponent',
        'IsHardwareConfiguration',
        'IsHWDevice',
        'IsHWSubDevice',
        'IsHWSystem',
        'IsIcon',
        'IsImplInfo',
        'IsIncaFolder',
        'IsModelElement',
        'IsModule',
        'IsODXProject',
        'IsProject',
        'IsSignal',
        'IsStateMachine',
        'IsSubDeviceDescription',
        'IsSystemDescription',
        'IsTarget',
        'IsTask',
        'IsToolErrorAvailable',
        'AllDataSets',
        'Asap2Module',
        'GetAllDataSetNames',
        'GetAllWorkbases',
        obj=obj)

a2l = a[0].Asap2Module()
xx=a2l.GetAllElementNamesOfType('allMeasurements')
print(type(xx),xx)